<template>
  <div>
    <Header :left="true" leftText="返回" title="生产部门负责人调机审核" />
    <div>
      <van-tabs v-model="active" type="card" :offset-top="80" :sticky="true" @click="tabChange" swipeable
        style="top: 8px; font-size: 15px" color="#1c6c8d">
        <!-- 未确认页面 -->
        <van-tab title="未审核" style="font-size: 15px">
          <van-row style="margin-top: 20px">
            <van-col>
              <van-image width="40" height="30" style="margin-left: -10px" src="assets/block.png" />
            </van-col>
            <van-col class="message">未审核记录</van-col>
          </van-row>
          <div class="textScroll">
            <!-- 循环数据开始 -->
            <div v-for="item in itemsOne" :key="item.id">
              <div style="width: 100%; background-color: #f3f4f8; height: 5px">
                <span></span>
              </div>
              <div class="divStyle">
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="18" style="color: #a9a9a9">设备代码:{{ item.MachineID }}</van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px;color: #a9a9a9">
                  <van-col span="18">生产订单:{{ item.POrderID }}</van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px;color: #a9a9a9">
                  <van-col span="20">物料号:{{ item.MaterialID }}</van-col>
                  <van-col span="4">
                    <van-button color="#138087" @click.stop="confirmmessage(item)" style="
                            width: 85px;
                            height: 40px;
                            font-size: 12px;
                            position: absolute;
                            left: 80%;
                          " type="primary" text="操作处理" />
                  </van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="18" style="color: #a9a9a9">物料名称:{{ item.MaterialName }}</van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="18" style="color: #a9a9a9">调机通知单描述:{{ item.NoticeMemo }}</van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="18" style="color: #a9a9a9">生产时间: {{ item.ProDatetimeFrom }} 至 {{ item.ProDatetimeTo
                  }}</van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="6"> </van-col>
                  <van-col span="3"> </van-col>
                  <van-col span="6"> </van-col>
                  <!-- <van-col span="6">
                    <van-popover
                      v-model="showPopover"
                      trigger="click"
                      :actions="actions"
                      @select="onSelect"
                    >
                      <template #reference>
                        <van-button
                          type="warning"
                          style="
                            width: 85px;
                            height: 40px;
                            margin-bottom: 10px;
                            right: 5px;
                            font-size: 12px;
                          "
                          >延迟处理</van-button
                        >
                      </template>
                    </van-popover>
                  </van-col> -->
                </van-row>
              </div>
            </div>
            <!-- 循环数据结束 -->
            <!-- <van-empty v-if="itemsOne == ''" image="search" description="暂无数据" /> -->
          </div>
        </van-tab>
        <!-- 已确认页面 -->
        <van-tab title="已审核">
          <van-row style="margin-top: 20px">
            <van-col>
              <van-image width="40" height="30" style="margin-left: -10px" src="assets/block.png" />
            </van-col>
            <van-col class="message">已审核信息</van-col>
          </van-row>
          <div class="textScroll2">
            <!-- 循环数据开始 -->
            <div v-for="item2 in itemsTwo" :key="item2.id">
              <div style="width: 100%; background-color: #f3f4f8; height: 5px">
                <span></span>
              </div>
              <div class="divStyle">
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="18" style="color: #a9a9a9">设备代码:{{ item2.MachineID }}</van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="18" style="color: #a9a9a9">生产订单:{{ Number(item2.POrderID) }}</van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px;color: #a9a9a9">
                  <van-col span="20">物料号:{{ item2.MaterialID }}</van-col>
                  <van-col span="4">
                    <van-button color="#138087" @click.stop="showDetail(item2)" style="
                            width: 85px;
                            height: 40px;
                            font-size: 12px;
                            position: absolute;
                            left: 80%;
                          " type="primary" text="查看" />
                  </van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="18" style="color: #a9a9a9">物料名称:{{ item2.MaterialName }}</van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="18" style="color: #a9a9a9">调机通知单描述:{{ item2.NoticeMemo }}</van-col>
                </van-row>
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="18" style="color: #a9a9a9">生产时间: {{ item2.ProDatetimeFrom }} 至 {{ item2.ProDatetimeTo
                  }}</van-col>
                </van-row>
              </div>
            </div>
            <!-- 循环数据结束 -->
            <!-- <van-empty v-if="itemsTwo == ''" image="search" description="暂无数据" /> -->
          </div>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>
<script>
import {
  Popover,
  Icon,
  Button,
  CellGroup,
  Cell,
  Field,
  tab,
  tabs,
  Col,
  Row,
  Image as VanImage,
  Divider,
  Checkbox,
  Pagination,
  Panel,
  Toast,
  Dialog,
  List,
  Empty
} from "vant";
import { _httpClient as _httpClientApi } from "@/libs/api";
import { _httpClient } from "@/libs/apisie";
import { storage } from "@/libs/utils";
import {
  removeToken,
  getToken,
  setBaseApiFrefix,
  getBaseApiFrefix,
} from "@/libs/auth";
import { memory } from "@/libs/utils";
Vue.use(Empty);
Vue.use(Cell);
Vue.use(CellGroup);
Vue.use(tab);
Vue.use(tabs);
Vue.use(Button);
Vue.use(Col);
Vue.use(Row);
Vue.use(Icon);
Vue.use(VanImage);
Vue.use(Divider);
Vue.use(Checkbox);
Vue.use(Pagination);
Vue.use(Panel);
Vue.use(Dialog);
Vue.use(List);
Vue.use(Popover);
Vue.use(Toast);
import Header from "@/components/header.vue";
import apicloud from "@/libs/apicloud";
export default {
  name: "QCmachineconfirm",
  components: {
    Toast,
    Popover,
    Button,
    Header,
    Icon,
    CellGroup,
    Cell,
    Field,
    tab,
    tabs,
    Col,
    Row,
  },

  data() {
    return {
      showPopover: false,
      // 通过 actions 属性来定义菜单选项
      actions: [{ text: "延迟处理" }, { text: "填写单据" }],
      //动态加载数据
      loading: false,
      finished: false,
      allSelected: false,
      screenWidth: 0,
      checked: true,
      active: 2,
      currentPage: 1,
      user: [], //登录用户信息
      itemsOne: [],
      itemsTwo: [], //已确认明细
    };
  },
  created: function () {
    let oldHight = api.winWidth;
    this.screenWidth = oldHight;
    //获取当前系统登录用户
    this.user = JSON.parse(storage.get("user"));
    this.user.userId = this.user.userName;
    // alert(JSON.stringify(this.user));
    this.getUncheckedList();
    //this.queryWaitAssignList();
  },
  methods: {
    onSelect(action) {
      Toast(action.text);
    },
    //已指派数据动态加载
    onLoad() {
      //页数+1
      this.loadParams.pageNum = this.loadParams.pageNum + 1;
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        //this.queryCheckedAssignList();
        // 加载状态结束
        this.loading = false;

        this.finished = true;
      }, 1000);
    },
    //tab切换
    tabChange(name, title) {
      if (name == 0) {
        //查询未确认信息
        this.getUncheckedList();
      } else if (name == 1) {
        //查询已确认信息
        this.getCheckedList();
      }
    },
    //确认
    async confirmmessage(item) {
      api.openWin({
        name: "equipmentsj-QCmachineconfirmItem",
        url: "./equipmentsj-QCmachineconfirmItem.html",
        pageParam: {
          item: item
        },
        reload: true
      });
    },
    //详情展示
    showDetail(item) {
      api.openWin({
        name: "equipmentsj-QCmachineCheckedItem",
        url: "./equipmentsj-QCmachineCheckedItem.html",
        pageParam: {
          item: item,
        },
      });
    },
    //查询未确审核调机数据
    async getUncheckedList() {
      let _this = this;
      //alert(_this.user.userId);
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/QualityAbnormalNotice/GetList?PrdManagerChecked=false&PrdManagerUserID=" + _this.user.userId,
        );
        // alert(_httpClient.getApiPrefix() +
        //   "/QualityAbnormalNotice/GetList?PrdManagerChecked=false&PrdMangerUserID=" + _this.user.userId);
        // alert(JSON.stringify(res));
        if (res.Total === 0) {
          Toast.clear();
        } else {
          Toast.clear();
          _this.itemsOne = res.Data;
        }

      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //查询已审核调机数据
    async getCheckedList() {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/QualityAbnormalNotice/GetList?PrdManagerChecked=true&PrdMangerUserID=" + _this.user.userId,
        );
        if (res.Total === 0) {
          Toast.clear();
        } else {
          Toast.clear();
          _this.itemsTwo = res.Data;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
  },
};
</script>
<style>
body {
  background-color: White;
}

.pic {
  width: 100%;
  text-align: center;
}

.divMedia {
  margin-top: 10px;
  height: 190px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
}

.clickbtn {
  width: 1;
  margin: 5px 10px;
  line-height: 45px;
  border: 1px #ccc dashed;
  text-align: center;
}

.buttonRight {
  position: fixed;
  margin-top: -40px;
  right: 15px;
  width: 90px;
  height: 40px;
  background-color: #1c6c8d;
  border-color: #1c6c8d;
}

.buttonLeft {
  position: fixed;
  margin-top: -40px;
  right: 110px;
  width: 90px;
  height: 40px;
  background-color: #1c6c8d;
  border-color: #1c6c8d;
}

.message {
  font-size: 20px;
  margin-top: 0px;
  margin-left: -10px;
  font-weight: bold;
}

.divStyle {
  /* border: 1px solid #dcdcdc; */
  border-top-width: 3px;
  border-left-width: 3px;
  margin-left: 3px;
  margin-right: 3px;
  margin-top: 0px;
}

.pagination {
  position: fixed;
  bottom: 15px;
  width: 100%;
  color: rgb(0, 0, 255);
  text-align: center;
}

.textScroll {
  display: inline-block;
  position: fixed;
  top: 10.2rem;
  bottom: 1px;
  overflow: scroll;
  right: 0;
  width: 100%;
  margin-bottom: 0.5rem;
  z-index: 1;
}

.textScroll2 {
  display: inline-block;
  position: fixed;
  top: 10rem;
  left: 0;
  bottom: 1px;
  overflow-y: scroll;
  width: 100%;
  margin-bottom: 0.5rem;
  z-index: 1;
  overflow-x: hidden;
  /*解决ios上滑动不流畅*/
  -webkit-overflow-scrolling: touch;
}
</style>
